﻿using ITSM.Model.Entity;
using ITSM.Model.Model;
using ITSM.Service;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace ITSM.Controllers.KnowledgeBase
{
    [Route("api/[controller]")]
    [ApiController]
    public class KnowledgeBaseController : ControllerBase
    {
        private readonly IKnowledgeBase _knowledgeBase;
        public KnowledgeBaseController(IKnowledgeBase knowledgeBase)
        {
            _knowledgeBase = knowledgeBase;
        }

        // GET: api/<KnowledgeBaseController>
        [HttpPost]
        public IActionResult QueryKnowledgeBase(M_QueryKnowledgeBase m_Query)
        {
            if (string.IsNullOrWhiteSpace(m_Query.RYD_Company) || m_Query.Num == 0)
            {
                return NotFound();
            }
            return Ok(_knowledgeBase.QueryKnowledgeBase(m_Query));
        }
        // GET: api/<KnowledgeBaseController>
        [HttpGet("/api/AddCTR")]
        public IActionResult AddCTR(string RYD_Id)
        {
            if (string.IsNullOrWhiteSpace(RYD_Id))
            {
                return NotFound();
            }
            return Ok(_knowledgeBase.AddCTR(RYD_Id));
        }
        [HttpGet("/api/AddUseful")]
        public IActionResult AddUseful(string RYD_Id)
        {
            if (string.IsNullOrWhiteSpace(RYD_Id))
            {
                return NotFound();
            }
            return Ok(_knowledgeBase.AddUseful(RYD_Id));
        }
        [HttpGet("/api/AddUseless")]
        public IActionResult AddUseless(string RYD_Id)
        {
            if (string.IsNullOrWhiteSpace(RYD_Id))
            {
                return NotFound();
            }
            return Ok(_knowledgeBase.AddUseless(RYD_Id));
        }
    }
}
